package com.ruoyi.web.tdm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.tdm.domain.TdmLianJieShuJuKu;
import com.ruoyi.web.tdm.service.ITdmLianJieShuJuKuService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ID-12 -21 -31 链接数据库Controller
 * 
 * @author ly
 * @date 2022-03-11
 */
@RestController
@RequestMapping("/tdm/TdmLianJieShuJuKu")
public class TdmLianJieShuJuKuController extends BaseController
{
    @Autowired
    private ITdmLianJieShuJuKuService tdmLianJieShuJuKuService;

    /**
     * 查询ID-12 -21 -31 链接数据库列表
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmLianJieShuJuKu:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmLianJieShuJuKu tdmLianJieShuJuKu)
    {
        startPage();
        List<TdmLianJieShuJuKu> list = tdmLianJieShuJuKuService.selectTdmLianJieShuJuKuList(tdmLianJieShuJuKu);
        return getDataTable(list);
    }

    /**
     * 导出ID-12 -21 -31 链接数据库列表
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmLianJieShuJuKu:export')")
    @Log(title = "ID-12 -21 -31 链接数据库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmLianJieShuJuKu tdmLianJieShuJuKu)
    {
        List<TdmLianJieShuJuKu> list = tdmLianJieShuJuKuService.selectTdmLianJieShuJuKuList(tdmLianJieShuJuKu);
        ExcelUtil<TdmLianJieShuJuKu> util = new ExcelUtil<TdmLianJieShuJuKu>(TdmLianJieShuJuKu.class);
        util.exportExcel(response, list, "ID-12 -21 -31 链接数据库数据");
    }

    /**
     * 获取ID-12 -21 -31 链接数据库详细信息
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmLianJieShuJuKu:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tdmLianJieShuJuKuService.selectTdmLianJieShuJuKuById(id));
    }

    /**
     * 新增ID-12 -21 -31 链接数据库
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmLianJieShuJuKu:add')")
    @Log(title = "ID-12 -21 -31 链接数据库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmLianJieShuJuKu tdmLianJieShuJuKu)
    {
        return toAjax(tdmLianJieShuJuKuService.insertTdmLianJieShuJuKu(tdmLianJieShuJuKu));
    }

    /**
     * 修改ID-12 -21 -31 链接数据库
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmLianJieShuJuKu:edit')")
    @Log(title = "ID-12 -21 -31 链接数据库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmLianJieShuJuKu tdmLianJieShuJuKu)
    {
        return toAjax(tdmLianJieShuJuKuService.updateTdmLianJieShuJuKu(tdmLianJieShuJuKu));
    }

    /**
     * 删除ID-12 -21 -31 链接数据库
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmLianJieShuJuKu:remove')")
    @Log(title = "ID-12 -21 -31 链接数据库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdmLianJieShuJuKuService.deleteTdmLianJieShuJuKuByIds(ids));
    }
}
